﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using ServerYuGi.PythonRegister;
using ServerYuGi.ChainEffectManager;
using ManagementEffect;

namespace ServerYuGi
{
    public partial class SSupervisor
    {
        void Process_RESPONE_CHONBAI_NGUOICHOI_TAY(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            int SoLuongLaBai = (int)param[1];
            List<int> tmp = new List<int>();
            for (int i = 0; i < SoLuongLaBai; i++)
                tmp.Add((int)param[i + 2]);
            WaitManager.Wakeup(false, tmp);
        }
        
        void Process_RESPONE_CHONBAI_NGUOICHOI_BAN(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            int SoLuongLaBai = (int)param[1];
            List<int> tmp = new List<int>();
            for (int i = 0; i < SoLuongLaBai; i++)
                tmp.Add((int)param[i + 2]);
            WaitManager.Wakeup(false,tmp);
        }
        void Process_RESPONE_CANCEL(params object[] param)
        {
            WaitManager.Wakeup(true,new List<int>());
        }
        void Process_RESPONE_ASK(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            List<int> tmp = new List<int>();
            tmp.Add((int)param[1]);
            WaitManager.Wakeup(false, tmp);
        }
        void Process_RESPONE_CHONBAI_DOITHU_TAY(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            int SoLuongLaBai = (int)param[1];
            List<int> tmp = new List<int>();
            for (int i = 0; i < SoLuongLaBai; i++)
                tmp.Add((int)param[i + 2]);
            WaitManager.Wakeup(false, tmp);
        }
        void Process_RESPONE_CHONBAI_DOITHU_BAN(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            int SoLuongLaBai = (int)param[1];
            List<int> tmp = new List<int>();
            for (int i = 0; i < SoLuongLaBai; i++)
                tmp.Add((int)param[i + 2]);
            WaitManager.Wakeup(false, tmp);
        }
        void Process_RESPONE_CHONBAI_TRENBAN(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            int SoLuongLaBai = (int)param[1];
            List<int> tmp = new List<int>();
            for (int i = 0; i < SoLuongLaBai; i++)
                tmp.Add((int)param[i + 2]);
            WaitManager.Wakeup(false, tmp);
        }
        void Process_RESPONE_CHONBAI_DANHSACH(params object[] param)
        {
            if (!RevMSGmanager.CheckIDRespone((int)param[0]))
                return;
            int SoLuongLaBai = (int)param[1];
            List<int> tmp = new List<int>();
            for (int i = 0; i < SoLuongLaBai; i++)
                tmp.Add((int)param[i + 2]);
            WaitManager.Wakeup(false, tmp);
        }

        void Process_CARD_EXCUTE_SUMMON(params object[] param)
        {
            int IDExcute = (int)param[0];
            List<int> tmp = new List<int>();
            tmp.Add(IDExcute);            
            WaitManager.Wakeup(false,tmp);
        }
        void Process_CARD_EXCUTE_SPELL(params object[] param)
        {
            int IDExcute = (int)param[0];
            List<int> tmp = new List<int>();
            tmp.Add(IDExcute);
            SendMessage_CARD_DOITRANGTHAI_XONG_ToAll(IDExcute, YMSG.CARD_TRANGTHAI_DUNG_MO);
            WaitManager.Wakeup(false, tmp);
        }
        void Process_CARD_EXCUTE_TRAP(params object[] param)
        {
            int IDExcute = (int)param[0];
            List<int> tmp = new List<int>();
            tmp.Add(IDExcute);
            SendMessage_CARD_DOITRANGTHAI_XONG_ToAll(IDExcute, YMSG.CARD_TRANGTHAI_DUNG_MO);
            WaitManager.Wakeup(false, tmp);
        }

        void Process_API_SPECIALSUMMON_XONG(params object[] param)
        {
            int idPlayer = (int)param[0];
            List<byte> listbyte = new List<byte>() { (byte)(int)param[1], (byte)(int)param[2], (byte)(int)param[3], (byte)(int)param[4] };
            int CardTypeID = BitConverter.ToInt32(listbyte.ToArray(), 0);                 
            int idCard = (int)param[5];
            SPlayer OtherPlayer = LayPlayerKhacVoiID(idPlayer);
            SendMessage_API_SPECIALSUMMON_XONG_ToID(OtherPlayer.ID, param);

            //--------------------------------------------------------------------------------------------------------------------------//
            // 15/09/2010, Hau fix, dang ky cho la bai Speacial Summon
            
            int IDCardLenBai = (int)param[4]; //new
            SPlayer player = LayPlayer(idPlayer);
            SCard card = player.LayCardTrenBan(idCard);
            CardScript XMLCardScript = CScriptDB.GetScript(card.MyYBaseCard.Card_TypeID);
            if (XMLCardScript != null)
            {
                if (XMLCardScript.IsCheckFirst == YBool.True)
                    DangKiSript(card);
                else
                    pyregister.AddStore(XMLCardScript.GetListCheckPoint(), card.MyYBaseCard.ID);
            }           
            //---------------------------------------------------------------------------------------------------------------------------------------//
            
            ChainMnager.AddItemMultiChain(YCheckPoint.MONSTER_SPECIALSUMMMON, idPlayer, CardTypeID, idCard);
            
        }
       
    }
}
